home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
dwpdemo
/
dwp_dsp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
7KB
|
266 lines
#ifndef lint
static char SccsId[]= "@(#)dwp_dsp.c V1.8 3/15/95";
#endif
/*------------------------------------------------------------------
| file name -- dwp_disp.c
|
| functions Description
| --------- -----------
| InitWindow Initializes the window
| new_window Sets up the new window display.
| SetupDynamics Set up the dynamic display lists.
| draw_screen Draw the display onto the window.
| close_window Close the display for one window.
| TermDisplays Terminates and closes all the windows.
|
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvGR.h"
#include "Tfundecl.h"
#include "dwp_vars.h"
#include "VTfundecl.h"
#include "VUfundecl.h"
#include "VOfundecl.h"
#include "GRfundecl.h"
#include "dwp_fundecl.h"
#define DEFAULT_SIZE (RECTANGLE*)NULL
#define DEFAULT_PORTION (RECTANGLE*)NULL
#define NEW_LIST (char)0
#define ADD_TO_LIST (char)1
#define DELETE_FROM_LIST (char)2
/*-----------------------------------------------------------------
|
| InitWindow
| Performs the initialization needed for the display.
|
| A SCREEN is opened using DVDEVICE and other attributes.
|
*/
void
InitWindow (which)
int which;
{
/* Open the window */
new_window (Device,
window_size[which].x, window_size[which].y,
window_name[which],
window_offset[which].x, window_offset[which].y,
which);
/* Initialize the window events */
InitSimpleEvents ();
/* Call RebindData() to rebind to application data */
RebindData (view[which]); /* found in dwp_rebind.c */
SetupDynamics (which);
draw_screen (which);
ActiveScreenIndex = which;
}
/*---------------------------------------------------------------
| new_window
| Create a new window with the specified view.
|
*/
void
new_window (device, width, height, name, x, y, window_number)
char *device;
int width;
int height;
char *name;
int x;
int y;
int window_number;
{
RECTANGLE wvp, dummy;
int error_code;
char buf[50];
if (window_status[window_number] == OPEN)
return;
/* Set the WaitingForExpose flag. This flag will be used
| to block updates in our TimeOutProc - HandleDynamics
*/
WaitingForExpose = YES;
if (width == -1 || height == -1)
DVscreen[window_number] = TscOpenSet (device, NULL,
V_WINDOW_NAME, name,
V_WINDOW_X, x,
V_WINDOW_Y, y,
#ifdef WINNT
V_WIN32_ICON_NAME, "dwpicon",
#ifdef DOUBLE_BUFFER
V_WIN32_DOUBLE_BUFFER, YES,
#endif /* DOUBLE_BUFFER */
#else /* Not WINNT */
V_X_EXPOSURE_BLOCK, YES,
#endif /* WINNT */
V_ACTIVE_CURSOR,
V_END_OF_LIST);
else
DVscreen[window_number] = TscOpenSet (device, NULL,
V_WINDOW_WIDTH, width,
V_WINDOW_HEIGHT, height,
V_WINDOW_NAME, name,
V_WINDOW_X, x,
V_WINDOW_Y, y,
#ifdef WINNT
V_WIN32_ICON_NAME, "dwpicon",
#ifdef DOUBLE_BUFFER
V_WIN32_DOUBLE_BUFFER, YES,
#endif /* DOUBLE_BUFFER */
#else /* Not WINNT */
V_X_EXPOSURE_BLOCK, YES,
#endif /* WINNT */
V_ACTIVE_CURSOR,
V_END_OF_LIST);
if(!DVscreen[window_number])
{
error_code=TscOpenError();
#ifdef WINNT
sprintf(buf,"Product is not validated. Error code %d.",error_code);
MessageBox(NULL,buf,"Validation Error",MB_OK);
#else
fprintf(stderr,"Product is not validated. Error code %d.",error_code);
#endif
exit(error_code);
}
view[window_number] = TviLoad (view_name[window_number]);
drawing[window_number] = TviGetDrawing (view[window_number]);
VOobBox (drawing[window_number], &wvp, &dummy);
drawport[window_number] = TdpCreateStretch (DVscreen[window_number],
view[window_number],
(RECTANGLE *) NULL, &wvp);
dsl[window_number] = TviGetDataSourceList (view[window_number]);
(VOID) TdlOpenData (dsl[window_number]);
/* Reset the WaitingForExpose flag so updates can continue */
WaitingForExpose = NO;
return;
}
/*----------------------------------------------------------------
| draw_screen
| Draw the drawport onto the screen and set status variables.
|
*/
void
draw_screen (window_number)
int window_number;
{
(VOID) TscErase (DVscreen[window_number]);
(VOID) TdpDraw (drawport[window_number]);
(VOID) GRset (V_ACTIVE_CURSOR, 0L);
window_status[window_number] = OPEN;
if ((window_number == HELP) || (window_number == LEGEND))
dynamic_status[window_number] = OFF;
else
dynamic_status[window_number] = ON;
return;
}
/*-------------------------------------------------------------
|
| SetupDynamics
| Set up the dynamics for the specified window.
|
*/
void
SetupDynamics (window_number)
int window_number;
{
switch (window_number)
{
case MAIN:
setup_main_window ();
break;
case AMMONIA:
setup_ammonia_window ();
break;
case HP_DRUM:
setup_hp_drum_window ();
break;
case LP_DRUM:
setup_lp_drum_window ();
break;
case HAND:
setup_hand_window ();
break;
case HELP:
break;
case LEGEND:
break;
} /* end switch ( window_number ) */
}
/*---------------------------------------------------------------
|
| close_window
| Close the specified window.
|
*/
void
close_window (window_number)
int window_number;
{
if (window_status[window_number] == OPEN)
{
(VOID) TdlCloseData (dsl[window_number]);
(VOID) VOscSelect (DVscreen[window_number]);
(VOID) TdpDestroy (drawport[window_number]);
(VOID) TscClose (DVscreen[window_number]);
window_status[window_number] = CLOSED;
dynamic_status[window_number] = OFF;
DVscreen[window_number] = (LONG)NULL;
}
}
/*-----------------------------------------------------------------
|
| TermDisplays
| Performs the termination and clean up needed for the display
| components.
|
*/
void TermDisplays
V_P_ ((void))
{
INT i;
/* Destroy, Erase and Close the Windows */
for (i = (MAXWINS - 1); i >= 0; i--)
if (window_status[i] == OPEN)
{
if (dynamic_status[i] == ON)
/* Destroy the Dynamic Object Deque */
VOdqDereference (displaydq[i]);
/* Close the window */
close_window (i);
}
}